package com.aegean.MonitorExamSYS.conduction.action;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.SQLException;
import javax.annotation.Resource;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.aegean.MonitorExamSYS.conduction.business.ConductionBusiness;
import com.aegean.MonitorExaxSYS.model.MonitorValue;
import com.opensymphony.xwork2.ActionSupport;
@Controller("showMonitorPhoto")
@Scope("prototype")
public class showMonitorPhoto extends ActionSupport {
	InputStream monitor_Photo;
	String photoName;
	MonitorValue monitor;
	private int monitor_Id;
	public int getMonitor_Id() {
		return monitor_Id;
	}

	public void setMonitor_Id(int monitor_Id) {
		this.monitor_Id = monitor_Id;
	}
	@Resource
	ConductionBusiness business;
	public InputStream getmonitor_Photo() {
		return monitor_Photo;
	}

	public void setmonitor_Photo(InputStream monitor_Photo) {
		this.monitor_Photo = monitor_Photo;
	}

	public String getPhotoName() {
		return photoName;
	}

	public void setPhotoName(String photoName) {
		this.photoName = photoName;
	}

	public String getPhotoType() {
		return photoType;
	}

	public void setPhotoType(String photoType) {
		this.photoType = photoType;
	}

	String photoType;

	public InputStream getDownload() {
		try {
			monitor = business.showMonitorPhoto(monitor_Id);
			monitor_Photo=monitor.getUser_Photo().getPhoto().getBinaryStream();
			photoName = monitor.getUser_Photo().getPhoto_Name();
			photoType = monitor.getUser_Photo().getPhoto_Type();
			return monitor_Photo;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		}
	}
	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}

}
